<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <!--Meta Informations-->
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="referrer" content="no-referrer">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!--Site Title-->
    <title>信息修改</title>

    <!--Favicons-->
    <link rel="apple-touch-icon" sizes="60x60" th:href="@{assets/favicon/logo2.png}">
    <link rel="icon" type="image/png" th:href="@{assets/favicon/logo5.png}" sizes="32x32">
    <link rel="icon" type="image/png" th:href="@{assets/favicon/logo4.png}" sizes="16x16">
    <link rel="manifest" th:href="@{assets/favicon/manifest.json}">
    <link rel="mask-icon" th:href="@{assets/favicon/safari-pinned-tab.svg}" color="#5bbad5">
    <link rel="shortcut icon" th:href="@{assets/favicon/logo3.png}">
    <meta name="msapplication-config" content="assets/favicon/browserconfig.xml">
    <meta name="theme-color" content="#ffffff">

    <!--Style Assets-->
    <link th:href="@{echarts/tree.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{bootstrap/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{vendors/fontawesome/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{vendors/owl/owl.carousel.css}">
    <link rel="stylesheet" th:href="@{vendors/magnific/magnific-popup.css}">
    <link rel="stylesheet" th:href="@{vendors/bootstrap-select/css/bootstrap-select.min.css}">

    <!--Theme Style-->
    <link rel="stylesheet" th:href="@{assets/css/styles.css}">

    <style>
        .vali_pass {
            width: 350px;
            margin: 0 auto;
            padding: 10px;
            border: #eee 1px solid;
            text-align: center;
        }

        .vali_pass input {
            width: 96%;
            display: block;
            margin: 0;
            padding: 5px;
            font-size: 14px;
            line-height: 20px;
        }

        .vali_pass_progress {
            width: 504px;
            margin-top: 10px;
            background-color: #efefef;
            height: 10px;
            border-radius: 5px;
        }

        .vali_pass_inner_progress {
            display: block;
            height: 100%;
            background-color: transparent;
            border-radius: 5px;
            width: 504px;
        }

        .error {
            background-color: #ff3300;
        }

        .middle {
            background-color: gold;
        }

        .strong {
            background-color: green;
        }
    </style>

</head>
<body onkeydown="on_return();">

<div id="page" class="site row">

    <header id="header" class="site-header">

        <nav class="navbar navbar-defatult navbar-fixed-top fluid-navbar navbar-style1">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a th:href="@{/}" class="navbar-brand">
                        <img th:src="@{assets/icons/logo9.png}" alt="" class="logo-img"/></a>
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-nav"
                            aria-expanded="false">
                        <span class="sr-only">Nav Opener</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                </div>
                <div class="collapse navbar-collapse" id="main-nav">
                    <ul class="navbar-nav nav navbar-right">
                        <li><a th:href="@{/}">主页</a></li>
                        <li><a th:href="@{personal_center}" class="mark-img" data-spm-anchor-id="5176.12281949.0.0">
                            <img class="userPhoto" style="width: 22px; height: 22px; vertical-align: middle; margin-right: 10px;
                                        border-radius: 15px;" src="https://ucc.alicdn.com/avatar/avatar3.jpg">
                            <span th:text="${user.getName()}"></span>
                        </a>
                        </li>
                        <li><a th:href="@{login}">退出登录</a></li>
                    </ul>
                </div>
            </div>
        </nav>

        <!--Page Cover-->
        <section class="row page-cover" data-slide="assets/images/slide1.jpg" style="padding-bottom: 10px">
            <div class="container">
                <h2 class="this-title" style="color: white">信息修改</h2>
            </div>
        </section>

    </header>

    <main id="contents" class="site-contnts">

        <!--Blogs-->
        <section class="row blog-section" style="padding: 200px 0px">
            <div class="container">
                <div class="row">
                    <div class="col-md-4 sidebar">
                        <aside class="row widget widet_search">
                            <div class="media service-quote">
                                <div class="media-left" style="padding-left: 0px"><a href="/personal_center" class="media-object"><img
                                        th:src="@{assets/images/service-quote.png}" alt="HostPro Client image"
                                        class="img-circle"></a></div>
                                <div class="media-body">
                                    <h4 th:text="${user.getName()}"></h4>
                                    <h5 th:text="${user.getEmail()}"></h5>
                                    <p><em th:text="${user.getSign()}"></em></p>
                                </div>
                                <div class="media-right"><span class="media-object"><img
                                        th:src="@{assets/icons/service-quote2.png}"
                                        alt="HostPro Service Quote Sign"></span></div>
                            </div>
                        </aside>
                        <aside class="row widget widget_categories">
                            <ul>
                                <li class="cat-info">今天是您来到Mlearning的第<b style="color: #f5994e" th:text="${days+1}"></b>天
                                </li>
                                <li class="cat-info">共掌握<b style="color: #f5994e" th:text="${masteredQuan}"></b>个知识点
                                </li>
                                <li class="cat-info">共收藏<b style="color: #f5994e" th:text="${myBooksQuan}"></b>本书籍</li>
                            </ul>
                        </aside>
                        <aside class="row widget widget_tag_cloud">
                            <h5 class="widget-title">您可能对以下知识感兴趣</h5>
                            <div class="tagcloud">
                                <a style="margin-right: 5px" class="tag-link-1" th:each="know:${recKnow}"
                                   th:text="${know}"></a>
                            </div>
                        </aside>
                    </div>
                    <div class="col-md-8" style="padding-left: 10%">
                        <label class="searchform input-group" style="font-size: 17px">昵称
                            <input type="search" id="nickname" class="form-control" th:value="${user.getName()}"
                                   maxlength="10" size="50" readonly="readonly">
                            <img sort="1" class="checkblue" th:src="@{assets/icons/check-blue.png}"
                                 style="display: none"
                                 onclick="$(this).attr('style','display:none');$(this).next().removeAttr('style');$('#nickname').attr('readonly','readonly'); edit($(this).attr('sort'), $(this).prev().val());"/>
                            <img th:src="@{assets/icons/edit.png}"
                                 onclick="$(this).attr('style','display:none');$(this).prev().removeAttr('style');$('#nickname').removeAttr('readonly');"/>
                        </label>
                        <br/>
                        <label class="searchform input-group" style="font-size: 17px">状态
                            <input type="search" id="sign" class="form-control" th:value="${user.getSign()}"
                                   maxlength="25" size="50" readonly="readonly">
                            <img sort="2" class="checkblue" th:src="@{assets/icons/check-blue.png}"
                                 style="display: none"
                                 onclick="$(this).attr('style','display:none');$(this).next().removeAttr('style');$('#sign').attr('readonly','readonly'); edit($(this).attr('sort'), $(this).prev().val());"/>
                            <img th:src="@{assets/icons/edit.png}"
                                 onclick="$(this).attr('style','display:none');$(this).prev().removeAttr('style');$('#sign').removeAttr('readonly');"/>
                        </label>
                        <br/>
                        <label class="searchform input-group" style="font-size: 17px">邮箱
                            <input type="search" id="email" class="form-control" th:value="${user.getEmail()}"
                                   maxlength="40" size="50" readonly="readonly">
                            <img class="checkemail" th:src="@{assets/icons/check-blue.png}" style="display: none"/>
                            <img th:src="@{assets/icons/edit.png}"
                                 onclick="$(this).attr('style','display:none');$(this).prev().removeAttr('style');$('#email').removeAttr('readonly');"/>
                        </label>
                        <p id="check_email"
                           style="text-align: center;color:red;display: none;background-color: #eeeeee;width: 504px"
                           class="form-control"></p>
                        <br/>
                        <hr style="width:550px;color:#f5994e;size: 3px" align="center">
                        <p><em style="font-size: 20px">密码修改</em></p>
                        <hr style="width:550px;color:#f5994e;size: 3px" align="center">
                        <br/>
                        <label class="searchform input-group" style="font-size: 17px">原密码
                            <input type="password" id="passward" class="form-control" size="50">
                        </label>
                        <p id="checkpw" class="form-control"
                           style="text-align: center;display: none;background-color: #eeeeee;width: 504px"></p>
                        <br/>
                        <label class="searchform input-group" style="font-size: 17px">新密码
                            <input type="password" id="newpwd1" class="form-control" maxlength="15" size="50">
                        </label>
                        <div class="vali_pass_progress"><span class="vali_pass_inner_progress"></span></div>
                        <p id="prompt_1" class="form-control"
                           style="text-align: center;display: none;background-color: #eeeeee;width: 504px"></p>
                        <br/>
                        <label class="searchform input-group" style="font-size: 17px"><text style="display: block;">确认密码</text>
                            <input type="password" id="newpwd2" class="form-control" maxlength="15" size="50" style="width: 504px">
                        </label>
                        <p id="prompt" class="form-control"
                           style="text-align: center;display: none;background-color: #eeeeee;width: 504px"></p>
                        <br/>
                        <button class="reply-link btn-primary btn checkpwd"
                                style="font-size: 17px;width: 504px;height: 50px;position: relative">确认密码修改
                        </button>
                    </div>
                </div>
            </div>
        </section>

    </main>

    <!--Footer-->
    <footer id="footer" class="site-footer">
        <!--Footer Bottom-->
        <section class="row site-footer-bottom">
            <div class="container">
                <div class="row">
                    <div class="col-sm-6 widget-footer">
                        <div class="row widget-content">
                            <ul class="menu">
                                <li style="color: #939393">鲁ICP备20006308</li>
                                <li>
                                    <a target="_blank"
                                       href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=37011202000992"
                                       style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">
                                        <img th:src="@{assets/images/beian.png}" style="float:left;"/>
                                        <p style="float:left;height:20px;line-height:20px;margin: 0 0 0 5px; color:#939393;">
                                            鲁公网安备 37011202000992号</p>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </footer>

</div>
<!--modal-->
<div class="modal fade" id="saveKnow">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <h4 class="modal-title" align="center">收藏知识</h4>
                <br/>
                <div class="row" align="center">
                    <span class="recKnowledge" style="color: #c7254e"></span>
                </div>
                <div class="row">
                    <div style="height: 30px"></div>
                </div>
                <div class="row " align="center" th:each="tree:${user.getTrees()}">
                    <div class="col-sm-12">
                        <span class="col-md-offset-1" style="font-size: 15px">第</span><span
                            th:text="${treeStat.index+1}"
                            style="color: #c7254e;font-size: 15px"></span><span
                            style="font-size: 15px">棵知识树</span><span>&nbsp;&nbsp;&nbsp;</span><span
                            th:text="${tree.getKnows()[0]}" style="font-size: 15px"></span><span>...</span><span
                            style="font-size: 15px"
                            th:text="${tree.getKnows()[tree.getKnows().size()-1]}"></span>
                        <span class="btn btn-default btn-primary saveKnow" th:if="${tree.getKnows().size()}<10"
                              th:tree="${treeStat.index+1}" th:sort="${tree.getKnows().size()+1}">收藏至此</span>
                        <span class="btn btn-default btn-primary" disabled
                              th:if="${tree.getKnows().size()}==10">已达上限</span>
                    </div>
                </div>
                <div class="row " align="center">
                    <div class="col-sm-offset-3 col-sm-3">
                        <a target="_blank" onclick=" $('#saveKnow').modal('hide');"
                           class="btn btn-default btn-block btn-primary relBook">查看书籍</a>
                    </div>
                    <div class="col-sm-3" th:if="${user.getTrees().size()}<5">
                        <span class="btn btn-default btn-primary saveKnow" th:tree="${user.getTrees().size()+1}"
                              sort="1">收藏至新知识树</span>
                    </div>
                </div>
                <br/>

            </div>
            <div class="modal-footer">
            </div>
        </div>
        <!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--modal-->
<div class="modal fade" id="checkEmail" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <h4 class="modal-title" align="center">修改提示</h4>
                <br/>
                <div class="row" align="center">
                    <span style="font-size: 15px">我们已向您的新邮箱<span id="newEmail"
                                                                 style="color: #c7254e;font-size: 15px"></span>发送了一封邮件</span>
                    <br/>
                    <span style="font-size: 15px">长时间没有收到时，请检查您输入的邮箱地址是否正确。</span>
                    <span style="font-size: 15px">请将验证码填入下方</span>
                </div>
                <br/>
                <div class="row" align="center">
                    <input id="code" class="col-sm-offset-3 col-sm-3" width="30px" maxlength="10" placeholder="验证码">
                    <span id="emailSure" class="btn col-sm-offset-1 col-sm-2" style="color: #ff6726">确认</span>
                    <br/>
                    <p id="check_code"
                       style="text-align: center;display: none;background-color: #eeeeee"
                       class="form-control"></p>
                </div>
                <br/>
            </div>
            <div class="modal-footer">
            </div>
        </div>
        <!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--modal-->
<div class="modal fade" id="checkPwd">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <h4 class="modal-title" align="center">修改提示</h4>
                <br/>
                <div class="row" align="center">
                    <span>请按照提示纠正输入！</span>
                    <br>
                    <span>昵称、状态、邮箱修改，点击蓝勾即可；密码修改提交，点击确认密码修改即可。</span>
                </div>
                <br/>
            </div>
            <div class="modal-footer">
            </div>
        </div>
        <!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--modal-->
<div class="modal fade" id="emailExist" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <h4 class="modal-title" align="center">抱歉</h4>
                <br/>
                <div class="row" align="center">
                    <span style="font-size: 15px">该邮箱已注册！</span>
                </div>
                <br/>
            </div>
            <div class="modal-footer">
            </div>
        </div>
        <!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script th:src="@{vendors/jquery.min.js}"></script>
<script th:src="@{bootstrap/js/bootstrap.min.js}"></script>
<script th:src="@{vendors/owl/owl.carousel.min.js}"></script>
<script th:src="@{vendors/mcustomscrollbar/jquery.mCustomScrollbar.concat.min.js}"></script>
<script th:src="@{vendors/magnific/jquery.magnific-popup.min.js}"></script>
<script th:src="@{vendors/isotope.pkgd.min.js}"></script>
<script th:src="@{vendors/imagesloaded.pkgd.min.js}"></script>
<script th:src="@{vendors/form-validator/jquery.form.js}"></script>
<script th:src="@{vendors/form-validator/jquery.validate.min.js}"></script>
<script th:src="@{vendors/waypoint/waypoints.min.js}"></script>
<script th:src="@{vendors/couterup/jquery.counterup.min.js}"></script>
<script th:src="@{vendors/bootstrap-select/js/bootstrap-select.min.js}"></script>
<!--Theme JS-->
<script th:src="@{assets/js/hostpro.js}"></script>

<script>
    function on_return() {
        if (window.event.keyCode === 13) {
            $('.checkblue').each(function () {
                if ($(this).attr('style') == null) {
                    $(this).click();
                }
            });
        }
    }
</script>
<script type="text/javascript">
    $(function () {
        $(".tag-link-1").click(function () {
            $('.recKnowledge').text($(this).text());
            $('.relBook').attr('href', 'book?search=' + $(this).text());
            $('#saveKnow').modal('show'); //显示模态框
        });
    });

</script>

<script th:src="@{sha/sha1.js}"></script>
<script>
    $(function () {
        function edit(sort, content) {
            $.ajax({
                url: 'func/edit',
                type: 'post',
                data: {'sort': sort, 'content': content},
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.message === 200) {
                        if (sort === "4") {
                            window.location.href = '/login';
                        }else {
                            location.reload();
                        }
                    }
                },
                error: function (data) {
                    console.log('func edit error')
                }
            })
        }

        $(".checkblue").click(function () {
            edit($(this).attr('sort'), $(this).prev().val());
        });

        /*
        判断邮箱是否可用
        */
        var can_flag_3 = false;
        // $("#email").blur(function () {
        //     var email = $("#email").val();
        //     $.ajax({
        //         url:'/checkuseremail?email='+email,
        //         typr:'get',
        //         success:function (data) {
        //             document.getElementById("check_email").innerText = data;
        //             document.getElementById("check_email").style.display = "";
        //
        //             if (data == "邮箱已被注册!") {
        //                 $("#email").focus();
        //                 document.getElementById("check_email").style.color = "red";
        //                 can_flag_3 = false;
        //             } else {
        //                 document.getElementById("check_email").style.display = "none";
        //                 can_flag_3 = true;
        //             }
        //         },
        //         error:function () {
        //             console.log('check email error');
        //         }
        //     });
        // });

        /*
        发送验证吗
        */
        $(".checkemail").click(function () {
            // $(".checkemail").focus();

            var email = $("#email").val();
            $.ajax({
                url:'/checkuseremail?email='+email,
                typr:'get',
                success:function (data) {
                    document.getElementById("check_email").innerText = data;
                    document.getElementById("check_email").style.display = "";

                    if (data == "邮箱已被注册!") {
                        $("#email").focus();
                        document.getElementById("check_email").style.color = "red";
                        $('#emailExist').modal('show'); //显示模态框
                        can_flag_3 = false;
                    } else {
                        document.getElementById("check_email").style.display = "none";
                        can_flag_3 = true;

                            $('#newEmail').text($('#email').val());
                            //此处应该加入发送邮件
                            $.ajax({
                                type: "POST",
                                url: "SendEmailServlet?random=" + Math.random(),
                                data: {
                                    email: $('#email').val(),
                                },
                                success: function (data) {
                                    $('#checkEmail').modal('show'); //显示模态框
                                },
                                error: function (data) {
                                    document.getElementById("check_email").innerText = '发送验证码失败';
                                    document.getElementById("check_email").style.display = "";
                                    document.getElementById("check_email").style.color = "red";
                                }
                            });

                            $(this).attr('style', 'display:none');
                            $(this).next().removeAttr('style');
                            $('#email').attr('readonly', 'readonly');

                    }
                },
                error:function () {
                    console.log('check email error');
                }
            });


        });

        /*
        校验验证吗
        */
        $("#emailSure").click(function () {
            var code = $("#code").val();
            $.get("checkcode", {code: code},
                function (data) {
                    document.getElementById("check_code").innerText = data;
                    document.getElementById("check_code").style.display = "";

                    if (data == "验证码不正确") {
                        document.getElementById("check_code").style.color = "red";
                    }
                    if (data == "请点击发送验证码按钮！") {
                        document.getElementById("check_code").style.color = "red";
                    }
                    if (data == "验证成功") {
                        document.getElementById("check_code").style.display = "none";
                        edit("3", $('#newEmail').text());
                    }
                });
        });

        /*
         重设密码
         */
        var ele_pass = document.getElementById("newpwd1");
        var ele_pd2 = document.getElementById("newpwd2");
        var ele_progress = document.getElementsByClassName("vali_pass_inner_progress")[0];
        var begin_classname = ele_progress.className;
        var regxs = [];
        regxs.push(/[^a-zA-Z0-9_]/g);
        regxs.push(/[a-zA-Z]/g);
        regxs.push(/[0-9]/g);

        // 判断密码强度
        var can_flag_1 = false;
        var can_flag_2 = false;
        ele_pass.onkeyup = function () {
            var val = this.value;
            var len = val.length;
            var sec = 0;
            if (len >= 6) { // 至少六个字符
                for (var i = 0; i < regxs.length; i++) {
                    if (val.match(regxs[i])) {
                        sec++;
                    }
                }
            } else {
                document.getElementById("prompt_1").innerText = "密码不少于6位!";
                document.getElementById("prompt_1").style.color = "red";
                document.getElementById("prompt_1").style.display = "";
                ele_pass.focus();
                can_flag_1 = false;
                // document.getElementById("sub").disabled = true;
            }
            var result = (sec / regxs.length) * 100;
            ele_progress.style.width = result + "%";
            if (result > 0 && result <= 50) {
                ele_progress.setAttribute("class", begin_classname + " error");

                if (old_pd.value === ele_pass.value) {
                    document.getElementById("prompt_1").innerText = "原密码和新密码不能相同";
                    document.getElementById("prompt_1").style.color = "red";
                    document.getElementById("prompt_1").style.display = "";
                    ele_pass.focus();
                    can_flag_1 = false;
                } else {
                    document.getElementById("prompt_1").innerText = "密码强度：低";
                    document.getElementById("prompt_1").style.color = "black";
                    document.getElementById("prompt_1").style.display = "";
                    can_flag_1 = true;
                }
            } else if (result > 50 && result < 100) {
                ele_progress.setAttribute("class", begin_classname + " middle");

                if (old_pd.value === ele_pass.value) {
                    document.getElementById("prompt_1").innerText = "原密码和新密码不能相同";
                    document.getElementById("prompt_1").style.color = "red";
                    document.getElementById("prompt_1").style.display = "";
                    ele_pass.focus();
                    can_flag_1 = false;
                } else {
                    document.getElementById("prompt_1").innerText = "密码强度：中";
                    document.getElementById("prompt_1").style.color = "black";
                    document.getElementById("prompt_1").style.display = "";
                    can_flag_1 = true;
                }
            } else if (result == 100) {
                ele_progress.setAttribute("class", begin_classname + " strong");

                if (old_pd.value === ele_pass.value) {
                    document.getElementById("prompt_1").innerText = "原密码和新密码不能相同";
                    document.getElementById("prompt_1").style.color = "red";
                    document.getElementById("prompt_1").style.display = "";
                    ele_pass.focus();
                    can_flag_1 = false;
                } else {
                    document.getElementById("prompt_1").innerText = "密码强度：高";
                    document.getElementById("prompt_1").style.color = "black";
                    document.getElementById("prompt_1").style.display = "";
                    can_flag_1 = true;
                }
            }
        };

        // 判断密码一致性
        ele_pd2.onkeyup = function () {
            var pd1 = ele_pass.value;
            var pd2 = ele_pd2.value;
            if (pd1 == pd2) {
                document.getElementById("prompt").innerText = "输入密码一致";
                document.getElementById("prompt").style.display = "none";
                can_flag_2 = true;
            } else {
                document.getElementById("prompt").innerText = "输入密码不一致";
                document.getElementById("prompt").style.color = "red";
                document.getElementById("prompt").style.display = "";
                can_flag_2 = false;
            }
        };

        //验证原密码
        var can_flag_3 = false;
        var old_pd = document.getElementById("passward");
        $("#passward").change(function () {
            $.ajax({
                url: '/checkpw?password=' + sha1(old_pd.value),
                type: 'post',
                success: function (data) {
                    if (data === 'true') {
                        document.getElementById("checkpw").style.display = "none";
                        can_flag_3 = true;
                    } else {
                        document.getElementById("checkpw").innerText = "密码不正确";
                        document.getElementById("checkpw").style.color = "red";
                        document.getElementById("checkpw").style.display = "";
                        $("#passward").focus();
                        can_flag_3 = false;
                    }
                },
                error: function () {
                    console.log("checkpw error")
                }
            })
        });

        var new_pd = document.getElementById("newpwd1");
        $(".checkpwd").click(function () {
            if (can_flag_1 && can_flag_2 && can_flag_3) {
                edit("4", sha1(new_pd.value));//此处的第二个参数，应加入sha1加密过后的新密码
            } else {
               $('#checkPwd').modal('show');
            }
        });
    });
</script>
<script type="text/javascript" th:inline="javascript">
    $(function () {
        $(".saveKnow").click(function () {
            tree = $(this).attr("tree");
            no = $(this).attr("sort");
            know = $('.recKnowledge').text();
            $.ajax({
                url: 'func/addKnowledge',
                type: 'post',
                data: {'tree': tree, 'know': know, 'no': no},
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.message === 200) {
                        location.reload();
                    }
                },
                error: function (data) {

                }
            });
            $('#saveKnow').modal('hide');
        })
    })
</script>

</body>
</html>